//
//  ElecStartView.swift
//  SBSafetyApp
//
//  Created by Lina on 2023/11/27.
//

import Foundation
import UIKit

class ElecStartView: UIView {
    let titleL = UILabel()
    let authorTF = CustomLabelEffect()
    let cooperateTF = CustomLabelEffect()

    let submitBtn = UIButton.createPrimaryLarge("提交")
    let cancelBtn = UIButton.createPrimaryBorderLarge("取消")

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func reloadUI(withModal modal: StandingBookTypeModal) {
        titleL.text = modal.typeLabel
        authorTF.value = BSUser.currentUser.nickName
    }
    
    func setupUI() {
        titleL.font = UIFont.systemFont(ofSize: 18)
        titleL.textColor = .hex("#306EC8")
        addSubview(titleL)
        titleL.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp.top).offset(40)
            make.left.equalTo(self.snp.left).offset(11)
        }
        
        authorTF.placeholder = "申请人"
        authorTF.arrowIV.isHidden = true
        addSubview(authorTF)
        authorTF.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(titleL.snp.bottom).offset(40)
            make.centerX.equalTo(self.snp.centerX)
            make.height.equalTo(52)
            make.width.equalTo(ScreenWidth - 20)
        }
        
        cooperateTF.placeholder = "协同人"
        addSubview(cooperateTF)
        cooperateTF.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(authorTF.snp.bottom).offset(10)
            make.centerX.equalTo(self.snp.centerX)
            make.height.equalTo(52)
            make.width.equalTo(ScreenWidth - 20)
        }
        
        addSubview(cancelBtn)
        cancelBtn.snp.makeConstraints { (make) -> Void in
            make.bottom.equalTo(self.safeAreaLayoutGuide.snp.bottom).offset(-10)
            make.height.equalTo(50)
            make.centerX.equalTo(self.snp.centerX)
            make.width.equalTo(ScreenWidth - 20)
        }
        
        addSubview(submitBtn)
        submitBtn.snp.makeConstraints { (make) -> Void in
            make.bottom.equalTo(cancelBtn.snp.top).offset(-10)
            make.height.equalTo(50)
            make.centerX.equalTo(self.snp.centerX)
            make.width.equalTo(ScreenWidth - 20)
        }
    }
}
